import javax.swing.*;
import java.awt.*;

class PanelTest extends JFrame {
    JPanel panel1 = new JPanel();
    JPanel panel2 = new JPanel();
    JPanel panel3 = new JPanel();
    JPanel panel4 = new JPanel();
    JPanel panel5 = new JPanel();
    JPanel panel6 = new JPanel();
    JButton button1 = new JButton("Button1");
    JButton button2 = new JButton("Button2");
    JButton button3 = new JButton("Button3");
    JButton button4 = new JButton("Button4");
    JButton button5 = new JButton("Button5");
    JButton button6 = new JButton("Button6");

    PanelTest() {
        setSize(200, 150);
        setVisible(true);
        setTitle("面板容器实例");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setLayout(new FlowLayout());
        add(panel1);
        add(panel2);
        add(panel3);
        add(panel4);
        add(panel5);
        add(panel6);
        panel1.add(button1);
        panel2.add(button2);
        panel3.add(button3);
        panel4.add(button4);
        panel5.add(button5);
        panel6.add(button6);
        panel1.setBackground(Color.red);
        panel2.setBackground(Color.cyan);
        panel3.setBackground(Color.blue);
        panel4.setBackground(Color.black);
        panel5.setBackground(Color.GRAY);
        panel6.setBackground(Color.pink);
        validate();
    }
}

public class Test1 {
    public static void main(String[] args) {
        new PanelTest();
    }
}
